const app = getApp();
const regeneratorRuntime = global.regeneratorRuntime = require("../libs/regenerator");
const co = require('../libs/co');
const passport = require("../services/passport/passport");

Page({

    onLoad: function(options) {
        app.launchOptions = options;
        /* !Do not Remove the follow line, used for build tool.*/
        /*{ComponentLaunchJs}*/
        console.log(options.inputVal);
        let keyName = options.inputVal;
        this.loadProducts(keyName);
    },
    loadProducts: function (keyName) {
      var that = this;
      co(function *() {
          let productService = require("../services/mall/productService");
          let products = yield productService.searchProductResult(keyName);
          console.log(products);
          that.setData({
              products: products
          });
      });
    },
    onReady:function(){

    },
    clickitem: function (e) {   //带着specId 去详情界面
        var specId = e.currentTarget.dataset.specid;
        wx.navigateTo({
            url: '/pages/page9?id=' + specId,
        })
    },
    /* !Do not Remove the follow line, used for build tool.*/
    /*{ComponentJs}*/

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }

});
